package com.ss.android.model;

import com.ss.android.common.util.json.KeyName;
import com.ss.android.common.util.UrlBuilder;

import org.json.JSONObject;

public abstract class AbsArticle extends BaseArticle {
    public static final class a {
        public int diggCount;
        public int buryCount;
        public int userDigg;
        public int userBury;
        public int userLike;
        public int likeCount;
        private int commentCount;
        private int userRepin;

        public a() {
            this.diggCount = -2147483648;
            this.buryCount = -2147483648;
            this.userDigg = -2147483648;
            this.userBury = -2147483648;
            this.commentCount = -2147483648;
            this.userRepin = -2147483648;
            this.userLike = -2147483648;
            this.likeCount = -2147483648;
        }

        public final boolean a(AbsArticle article) {
            boolean v3_1;
            boolean v0_1;
            int v6 = 8;
            int v5 = -2147483648;
            boolean v2 = false;
            if (article != null) {
                int[] v3 = new int[v6];
                v3[0] = this.diggCount;
                v3[1] = this.buryCount;
                v3[2] = this.userDigg;
                v3[3] = this.userBury;
                v3[4] = this.commentCount;
                v3[5] = this.userRepin;
                v3[6] = this.userLike;
                v3[7] = this.likeCount;
                int v0 = 0;
                while (true) {
                    if (v0 >= v6) {
                        v0 = 1;
                        break;
                    } else if (v3[v0] != v5) {
                        v0 = 0;
                    } else {
                        ++v0;
                        continue;
                    }

                    break;
                }

                if (v0 != 0) {
                    return false;
                }

                if (this.userLike != v5) {
                    v0_1 = this.userLike > 0 ? true : false;
                    if (v0_1 == article.userLike) {
                        v0_1 = false;
                    } else {
                        v0_1 = this.userLike > 0 ? true : false;
                        article.userLike = v0_1;
                        v0_1 = true;
                    }
                } else {
                    v0_1 = false;
                }

                if (this.likeCount != v5 && this.likeCount != article.likeCount) {
                    article.likeCount = this.likeCount;
                    v0_1 = true;
                }

                if (this.diggCount != v5 && this.diggCount != article.diggCount) {
                    article.diggCount = this.diggCount;
                    v0_1 = true;
                }

                if (this.buryCount != v5 && this.buryCount != article.buryCount) {
                    article.buryCount = this.buryCount;
                    v0_1 = true;
                }

                if (this.userDigg != v5) {
                    v3_1 = this.userDigg > 0 ? true : false;
                    if (v3_1 == article.userDigg) {
                    } else {
                        v0_1 = this.userDigg > 0 ? true : false;
                        article.userDigg = v0_1;
                        v0_1 = true;
                    }
                }

                if (this.userBury != v5) {
                    v3_1 = this.userBury > 0 ? true : false;
                    if (v3_1 == article.userBury) {
                    } else {
                        v0_1 = this.userBury > 0 ? true : false;
                        article.userBury = v0_1;
                        v0_1 = true;
                    }
                }

                if (this.commentCount != v5 && this.commentCount != article.commentCount) {
                    article.commentCount = this.commentCount;
                    v0_1 = true;
                }

                if (this.userRepin == v5) {
                    return v0_1;
                }

                v3_1 = this.userRepin > 0 ? true : false;
                if (v3_1 == article.userRepin) {
                    return v0_1;
                }

                if (this.userRepin > 0) {
                    v2 = true;
                }

                article.userRepin = v2;
                v0_1 = true;
            } else {
                label_34:
                v0_1 = false;
            }

            return v0_1;
        }
    }

    public final ItemType opItemType;
    public String tag;
    public int level;
    public long behotTime;
    public String shareUrl;
    public int commentCount;
    public int diggCount;
    public int buryCount;
    public int repinCount;
    @KeyName(value = "like_count")
    public int likeCount;
    public boolean userDigg;
    public boolean userBury;
    public boolean userRepin;
    @KeyName(value = "user_like")
    public boolean userLike;
    public long userRepinTime;
    public long statsTimestamp;
    public long clickTimestamp;
    public long impressionTimestamp;
    public boolean userDislike;
    @KeyName(value = "ban_comment")
    public boolean mBanComment;

    public AbsArticle(ItemType itemType, long groupId, long itemId, int aggrType) {
        super(groupId, itemId, aggrType);
        this.mBanComment = false;
        this.opItemType = itemType;
    }

    public final String a(String ttFrom, String utmSource) {
        String v0;
        if (android.support.design.a.isTextEmpty(this.shareUrl)) {
            v0 = "";
        } else {
            UrlBuilder builder = new UrlBuilder(this.shareUrl);
            if (!android.support.design.a.isTextEmpty(ttFrom)) {
                if (("weixin".equals(ttFrom)) || ("weixin_moments".equals(ttFrom))) {
                    builder.addParam("wxshare_count", 1);
                }

                builder.addParam("tt_from", ttFrom);
            }

            if (!android.support.design.a.isTextEmpty(utmSource)) {
                builder.addParam("utm_source", utmSource);
            }

            builder.addParam("utm_medium", "toutiao_android");
            builder.addParam("utm_campaign", "client_share");
            v0 = builder.build();
        }

        return v0;
    }

    public void initWithJO(JSONObject jo) {
        this.tag = jo.optString("tag", "");
        this.behotTime = jo.optLong("behot_time");
        this.shareUrl = jo.optString("share_url");
        this.commentCount = jo.optInt("comment_count");
        this.diggCount = jo.optInt("digg_count");
        this.buryCount = jo.optInt("bury_count");
        this.repinCount = jo.optInt("repin_count");
        this.likeCount = jo.optInt("like_count");
        this.userDigg = jo.optInt("user_digg") > 0;
        this.userBury = jo.optInt("user_bury") > 0;
        this.userLike = jo.optInt("user_like") > 0;
    }

    public String getItemKey() {
        String tag = this.tag;
        if (tag == null) {
            tag = "";
        }
        long v2 = this.itemId > 0 ? this.itemId : this.groupId;
        return v2 + tag;
    }

    public boolean skipDedup() {
        return false;
    }
}

